USE [master]
GO

IF  EXISTS (SELECT name FROM sys.databases WHERE name = N'pubdb')
DROP DATABASE [pubdb]
GO

USE [master]
GO

CREATE DATABASE [pubdb] ON  PRIMARY 
( NAME = N'pubdb', FILENAME = N'D:\db\pubdb.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'pubdb_log', FILENAME = N'D:\db\pubdb_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO

ALTER DATABASE [pubdb] SET COMPATIBILITY_LEVEL = 100
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [pubdb].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [pubdb] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [pubdb] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [pubdb] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [pubdb] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [pubdb] SET ARITHABORT OFF 
GO

ALTER DATABASE [pubdb] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [pubdb] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [pubdb] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [pubdb] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [pubdb] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [pubdb] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [pubdb] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [pubdb] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [pubdb] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [pubdb] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [pubdb] SET  DISABLE_BROKER 
GO

ALTER DATABASE [pubdb] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [pubdb] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [pubdb] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [pubdb] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [pubdb] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [pubdb] SET READ_COMMITTED_SNAPSHOT OFF 
GO

ALTER DATABASE [pubdb] SET HONOR_BROKER_PRIORITY OFF 
GO

ALTER DATABASE [pubdb] SET  READ_WRITE 
GO

ALTER DATABASE [pubdb] SET RECOVERY FULL 
GO

ALTER DATABASE [pubdb] SET  MULTI_USER 
GO

ALTER DATABASE [pubdb] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [pubdb] SET DB_CHAINING OFF 
GO

IF  EXISTS (SELECT * FROM sys.server_principals WHERE name = N'pubuser')
DROP LOGIN [pubuser]
GO

CREATE LOGIN [pubuser] WITH PASSWORD=N'admin@123', DEFAULT_DATABASE=[pubdb], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=ON
GO

ALTER LOGIN [pubuser] DISABLE
GO

USE [pubdb]
GO

IF  EXISTS (SELECT * FROM sys.database_principals WHERE name = N'pubuser')
DROP USER [pubuser]
GO

CREATE USER [pubuser] FOR LOGIN [pubuser] WITH DEFAULT_SCHEMA=[dbo]
GO
EXEC sp_addrolemember N'db_owner', N'pubuser'  
GO



